# -*- coding: utf-8 -*-

# Create your views here.
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect


from ..models import (
    Clientes,
    ItemsRemates,
)


# FACTURACION

def listado_items_facturar(request, clienteid):
    """Listado de items del remate vendidos"""
    if request.user.is_authenticated():
        cliente = Clientes.objects.get(pk=clienteid)
        todo = ItemsRemates.objects.filter(comprador=cliente, vendido=True)
        variables = RequestContext(request, {
            'todo': todo,
            'cliente': cliente,
        })
        return render_to_response('listado_itemsRemates_facturar.html', variables)
    else:
        return HttpResponseRedirect('/login/?next=%s' % request.path)
